<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改库存盘点')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-stocktaking-edit" th:object="${jtStocktaking}">
            <h4 class="form-header h4" th:text="#{stockTakingInformation}">库存盘点信息</h4>
            <input name="stocktakingId" th:field="*{stocktakingId}" type="hidden">
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">[[#{warehouse}]]：</label>
                    <div class="col-sm-8">
                        <input th:value="*{warehouseName}" class="form-control" type="text" readonly>
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">[[#{stocktakingNumber}]]：</label>
                    <div class="col-sm-8">
                        <input name="inventoryListNumber" th:field="*{inventoryListNumber}" class="form-control" type="text" readonly>
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">[[#{documentDate}]]：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="documentDate" th:value="${#dates.format(jtStocktaking.documentDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" readonly>
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">[[#{status}]]：</label>
                    <div class="col-sm-8">
                        <div class="radio-box" th:each="dict : ${@dict.getType('jt_inventory_status')}">
                            <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
                            <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">[[#{remark}]]：</label>
                    <div class="col-sm-8">
                        <textarea name="remark" class="form-control" rows="3">[[*{remark}]]</textarea>
                    </div>
                </div>
            </div>
            <h4 class="form-header h4" th:text="#{stockTakingInformation}">库存盘点明细信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "business/stocktaking";
        var statusDatas = [[${@dict.getType('jt_stocktaking_status')}]];

        $(function() {
            var options = {
                data: [[${jtStocktaking.jtStocktakingItemList}]],
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: i18n('serialNumber'),
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'productName',
                    align: 'center',
                    title: i18n('productName'),
                },
                {
                    field: 'productCode',
                    align: 'center',
                    title: i18n('sku'),
                },
                {
                    field: 'styleCode',
                    align: 'center',
                    title: i18n('spu')
                },
                {
                    field: 'spec',
                    align: 'center',
                    title: i18n('spec')
                },
                {
                    field: 'preInventoryQty',
                    align: 'center',
                    title: i18n('preStocktakingQuantity')//盘点前数量
                },
                {
                    field: 'postInventoryQty',
                    align: 'center',
                    title: i18n('postStocktakingQuantity')//盘点后数量
                },
                {
                    field: 'warehousePosition',
                    align: 'center',
                    title: i18n('warehousePosition')
                },
                {
                    field: 'profitLossQty',
                    align: 'center',
                    title: i18n('profitAndLossQuantity')
                },
                {
                    field: 'status',
                    align: 'center',
                    title: i18n('status'),
                    formatter: function(value, row, index) {
                        var name = $.common.sprintf("jtStocktakingItemList[%s].status", index);
                        return $.common.dictToSelect(statusDatas, value, name);
                    }
                },
                {
                    field: 'remark',
                    align: 'center',
                    title: i18n('remark')
                },
                {
                    field: 'createBy',
                    align: 'center',
                    title: i18n('createBy')
                },
                {
                    field: 'createTime',
                    align: 'center',
                    title: i18n('createTime')
                }]
            };
            $.table.init(options);
        });
    </script>

    <script th:inline="javascript">
        var ROOT = [[${#servletContext.contextPath}]];
        var LANG_COUNTRY = [[${#locale.language+'_'+#locale.country}]];

        //初始化i18n
        $.i18n.properties({
            path: ROOT + '/i18n/',//这里表示访问路径
            name: 'messages',//文件名开头
            language: LANG_COUNTRY,//文件名语言 例如en_US
            mode: 'map'//默认值
        });

        //i18n函数
        function i18n(msgKey) {
            try {
                return $.i18n.prop(msgKey);
            } catch (e) {
                return msgKey;
            }
        }
    </script>
</body>
</html>